<template>
	<view class="leagueWork">
		<tui-navigation-bar   :titleSize="18" :titleLineHeight="18" :titlefontWeight="800" :isOpacity="false"
			@init="initNavigation" title="加盟合作" backgroundColor="#fff" color="#000">
			<view class="tui-header-icon" :style="{ marginTop: top + 'px' }">
				<tui-icon name="arrowleft" color="#333" @click="back"></tui-icon>
			</view>
		</tui-navigation-bar>
		<view class="leagueWork_content" :style="{ marginTop: marginTp + 'px' }">
			<!-- 基础信息 -->
			<view class="infoTitle">
				<image class="contentImg" src="../../../../static/user/my/icon_line2@2x.png" mode="aspectFill"></image>
				<view class="contentText"><text>基础信息</text></view>
			</view>
			<view class="inputItem">
				<view class="label">合作商名称<text class="rquired">*</text></view>
				<view class="divide"></view>
				<view class="input">
					<tui-input v-model="form.companyName" padding="0" size="28" :borderBottom="false" :borderTop="false" placeholder="请输入名称" clearable></tui-input>
				</view>
			</view> 
			<view class="inputItem">
				<view class="label">负责人<text class="rquired">*</text></view>
				<view class="divide"></view>
				<view class="input">
					<tui-input v-model="form.contacts" padding="0" size="28" :borderBottom="false" :borderTop="false" placeholder="请输入姓名" clearable ></tui-input>
				</view>
			</view>
			<view class="inputItem">
				<view class="label">联系方式<text class="rquired">*</text></view>
				<view class="divide"></view>
				<view class="input">
					<tui-input v-model="form.phoneNumber" padding="0" size="28" :borderBottom="false" :borderTop="false" placeholder="请输入联系方式" clearable ></tui-input>
				</view>
			</view> 
			<view class="textareaItem">
				<view class="label">合作商信息<text class="rquired">*</text></view>
				<view class="divide"></view> 
					 <tui-textarea size="28" v-model="form.introduction" padding="0" :borderBottom="false" :borderTop="false" height="200rpx"   placeholder="请输入合作商信息..."></tui-textarea> 
			</view> 
		</view>
		  	<view class="footer">
					<tui-form-button :loading="isLoading" @click="tapApply" margin="24rpx 0 0 0"  radius="40rpx" size="32" color="#fff" width="690rpx" height="84rpx" background="#2FD7D3"> 
						提交申请
					</tui-form-button>
			</view>
	</view>
</template>

<script>
	import { addCollaborate } from "@/http/api/user/user.js"
	export default {
		data() {
			return {
				top: 0, //标题图标距离顶部距离
				marginTp: 0,
				isLoading:false,
				form:{
					companyName:'',//公司名称
					introduction:'',//简介信息
					contacts:'',//联系人
					phoneNumber:'',//联系方式
				}
			}
		},
		methods: {  
			initNavigation(e) {
				this.top = e.top;
				this.marginTp = e.height
			},
			back() {
				uni.navigateBack();
			},
			tapApply(){
				let self = this; 
				if (!self.form.companyName) {
					self.$utils.toast('请输入合作商名称');
					return false;
				}
				if (!self.form.contacts) {
					self.$utils.toast('请输入联系人名称');
					return false;
				}
				if (!self.form.phoneNumber) {
					self.$utils.toast('请输入手机号');
					return false;
				} else if (!self.$regexp.phone.test(self.form.phoneNumber)) {
					self.$utils.toast('请输入正确的手机号');
					return false;
				}
				if (!self.form.introduction) {
					self.$utils.toast('请输入合作商信息');
					return false;
				}
				self.isLoading=true
				addCollaborate(this.form).then(res=>{
					if(res.code===200){
						self.$utils.toast('申请提交成功');
						 uni.navigateBack();
					}
				})
				.finally(()=>{
					self.isLoading=false
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import './leagueWork.scss';
</style>